﻿using System.Runtime.InteropServices;

namespace CodingExercises._1_25;

public class IsPalindrome
{
    //检测字符串是否为回文
    public bool Method1(string input)
    {
        for (int i = 0; i < input.Length / 2; ++i)
        {
            if (input[i] != input[input.Length - 1 - i])
                return false;
        }

        return true;
    }

    public bool Method2(string input)
    {
        for (int i = 0; i < input.Length / 2; ++i)
        {
            if (input[i] != input[^(i + 1)])
                return false;
        }

        return true;
    }

    public bool Method3(string input)
    {
        return input.SequenceEqual(input.Reverse());
    }
}